
#ifndef _lidar209_POINTCLOUD_CONVERT_H_
#define _lidar209_POINTCLOUD_CONVERT_H_ 1

#include <diagnostic_updater/diagnostic_updater.hpp>
#include <diagnostic_updater/publisher.hpp>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/point_cloud2.hpp>
#include <tf2_ros/buffer.h>
#include <lidar209_msgs/msg/lidar209_scan_ch88.hpp>

#include <memory>
#include <string>


#include "rawdata.h"


namespace lidar209_pointcloud
{
class Convert final
    : public rclcpp::Node
{
public:
  explicit Convert(const rclcpp::NodeOptions & options);
  ~Convert() override {}
  Convert(Convert && c) = delete;
  Convert & operator=(Convert && c) = delete;
  Convert(const Convert & c) = delete;
  Convert & operator=(const Convert & c) = delete;

private:

  void processScan_ch88(const lidar209_msgs::msg::Lidar209ScanCH88::SharedPtr scanMsg);
  void processScan_ch176(const lidar209_msgs::msg::Lidar209ScanCH88::SharedPtr scanMsg);

  std::unique_ptr<lidar209_rawdata::RawData> data_;

  rclcpp::Subscription<lidar209_msgs::msg::Lidar209ScanCH88>::SharedPtr lidar209_scan_;
  rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr output_;

  tf2_ros::Buffer tf_buffer_;
  std::unique_ptr<lidar209_rawdata::DataContainerBase> container_ptr_;

  /// configuration parameters
  struct Config
  {
    int npackets;  // number of packets to combine
  };
  Config config_{};

  // diagnostics updater
  diagnostic_updater::Updater diagnostics_;
  double diag_min_freq_;
  double diag_max_freq_;
  std::unique_ptr<diagnostic_updater::TopicDiagnostic> diag_topic_;

};

} // namespace lidar209_pointcloud

#endif // _lidar209_POINTCLOUD_CONVERT_H_
